/*---------------------------------------------------------------------------*/
/*!				\file				HideUnhide.c
				\date				march 2010
				\author				TNick

				\brief				Code to actually do hide or show
    
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */
	#include	"Config.h"
	#include	<windows.h>
	#include	<Commctrl.h>
	
	#include	"main.h"
	
/*  INCLUDES    ============================================================ */
//
//
//
//
/*  DEFINITIONS    --------------------------------------------------------- */

/*  DEFINITIONS    ========================================================= */
//
//
//
//
/*  DATA    ---------------------------------------------------------------- */

/*  DATA    ================================================================ */
//
//
//
//
/*  FUNCTIONS    ----------------------------------------------------------- */


/* ------------------------------------------------------------------------- */
void			Do_HideSelected		(void)
{
	LVITEM			it;
	TCHAR			TxBf[256];
	unsigned		icnt;
	unsigned		i = 0;
	unsigned		inew = 0;
	
	if (CurrentState == STATE_HIDDEN) return;
	CurrentState = STATE_HIDDEN;
	
	memset(&it,0,sizeof(LVITEM));
	icnt = ListView_GetItemCount(hW_Ls_L);
	
	it.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT;
	it.iSubItem = 0;
	it.pszText = (TCHAR*)&TxBf;
	it.cchTextMax = 255;
	
	
	while (i < icnt)
	{
		if (ListView_GetCheckState(hW_Ls_L,i))
		{
			it.iItem = i;
			if (ListView_GetItem(hW_Ls_L, &it) == FALSE) break;
			inew = ListView_InsertItem(hW_Ls_R, &it);
			if (inew == -1) break;
			ListView_SetCheckState(hW_Ls_R, inew, TRUE);
			ListView_GetItemText(hW_Ls_L,i,1,(TCHAR*)&TxBf,255);
			ListView_SetItemText(hW_Ls_R,inew,1,(TCHAR*)&TxBf);
			if (ListView_DeleteItem(hW_Ls_L,i) == FALSE) break;
			ShowWindow((HWND)it.lParam,SW_HIDE);
		}
		else i++;
	}
	if (AppStgs.Flags & APPFL_HIDEME)
	{
		if 	(hWOpts != NULL) DestroyWindow(hWOpts);
		ShowWindow(hwMain,SW_HIDE);
	}
	Epcs = 0;
}
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
void			Do_UnHideSelected	(void)
{
	LVITEM			it;
	TCHAR			TxBf[256];
	unsigned		icnt ;
	unsigned		i = 0;
	unsigned		inew = 0;
	
	if (CurrentState == STATE_UNHIDDEN) return;
	CurrentState = STATE_UNHIDDEN;
	
	memset(&it,0,sizeof(LVITEM));
	icnt = ListView_GetItemCount(hW_Ls_R);
	
	
	it.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT;
	it.iSubItem = 0;
	it.pszText = (TCHAR*)&TxBf;
	it.cchTextMax = 255;
	
	while (i < icnt)
	{
		if (ListView_GetCheckState(hW_Ls_R,i))
		{
			it.iItem = i;
			if (ListView_GetItem(hW_Ls_R, &it) == FALSE) break;
			inew = ListView_InsertItem(hW_Ls_L, &it);
			if (inew == -1) break;
			ListView_SetCheckState(hW_Ls_L, inew, TRUE);

			ListView_GetItemText(hW_Ls_R,i,1,(TCHAR*)&TxBf,255);
			ListView_SetItemText(hW_Ls_L,inew,1,(TCHAR*)&TxBf);
			if (ListView_DeleteItem(hW_Ls_R,i) == FALSE) break;
			ShowWindow((HWND)it.lParam,SW_SHOW);
		}
		else i++;
	}
	
	if (AppStgs.Flags & APPFL_HIDEME) ShowWindow(hwMain,SW_SHOW);
	Epcs = 0;
	RefreshVisList();
}
/* ========================================================================= */


/*  FUNCTIONS    =========================================================== */
//
//
//
//
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
